package com.gupao.proxy;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * Created by luoli on 5/14/17.
 */
public class Meipo implements MethodInterceptor {

    public Object getInstance(Class clazz){
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(clazz);
        enhancer.setCallback(this);
        return enhancer.create();
    }

    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("我是GP媒婆：" + "得给你找个异性才行   两边都修改了  我要合并分支留下这句话");
        System.out.println("开始进行海选...");
        System.out.println("------------");
        methodProxy.invokeSuper(o, objects);
        System.out.println("------------");
        System.out.println("如果合适的话，就准备办事");
        return null;
    }


}

